'use strict';

const Op = require('sequelize').Op;

module.exports = appInfo => {
  const config = exports = {};
  config.keys = appInfo.name + '_1620783032002_1928';
  config.multipart = {};
  config.middleware = [];
  config.error = {};
  config.cluster = {
    listen: {
      port: 1598,
    },
  };
  /* 取消安全证书验证 */
  config.security = {
    csrf: {
      enable: false,
    },
    domainWhiteList: [ '*' ], // 白名单
  };
  config.view = {};
  /* 连接mysql配置 */
  config.sequelize = {
    dialect: 'mysql',
    host: 'localhost',
    port: 3306,
    database: 'example',
    username: 'root',
    password: '123456',
    operatorsAliases: {
      $eq: Op.eq,
      $ne: Op.ne,
      $gte: Op.gte,
      $gt: Op.gt,
      $lte: Op.lte,
      $lt: Op.lt,
      $not: Op.not,
      $in: Op.in,
      $notIn: Op.notIn,
      $is: Op.is,
      $like: Op.like,
      $notLike: Op.notLike,
      $iLike: Op.iLike,
      $notILike: Op.notILike,
      $regexp: Op.regexp,
      $notRegexp: Op.notRegexp,
      $iRegexp: Op.iRegexp,
      $notIRegexp: Op.notIRegexp,
      $between: Op.between,
      $notBetween: Op.notBetween,
      $overlap: Op.overlap,
      $contains: Op.contains,
      $contained: Op.contained,
      $adjacent: Op.adjacent,
      $strictLeft: Op.strictLeft,
      $strictRight: Op.strictRight,
      $noExtendRight: Op.noExtendRight,
      $noExtendLeft: Op.noExtendLeft,
      $and: Op.and,
      $or: Op.or,
      $any: Op.any,
      $all: Op.all,
      $values: Op.values,
      $col: Op.col,
    },
  };
  /* 配置允许跨域 */
  config.cors = {
    credentials: true,
    origin: '*',
    allowMethods: 'GET,PUT,POST,DELETE',
  };
  config.jwt = {
    secret: '2d166a58964df21c98df',
  };
  const userConfig = {};

  return {
    ...config,
    ...userConfig,
  };
};
